//
//  MKUIFillingFlowLayoutConstraint.h
//  MKUI
//	在水平方向|垂直方向上,进行流布局,头尾元素顶边,剩余的元素,以等间隔排列.
//  Created by sushangjin on 2018/12/15.
//  Copyright © 2018 sushangjin. All rights reserved.
//

#import "MKUILayoutConstraint.h"

NS_ASSUME_NONNULL_BEGIN

@interface MKUIFillingFlowLayoutConstraint : MKUILayoutConstraint
@property(nonatomic,assign) MKUILayoutConstraintDirection layoutDirection;//元素的流布局方向.默认为MKUILayoutConstraintDirectionVertical.水平布局时,元素从左到向右布局.垂直布局时,元素从上到下布局

@property(nonatomic,assign) MKUILayoutConstraintVerticalAlignment layoutVerticalAlignment;//当水平布局时,每个元素在自己的单元格容器内,在垂直方向上的位置.默认为MKUILayoutConstraintVerticalAlignmentCenter
@property(nonatomic,assign) MKUILayoutConstraintHorizontalAlignment layoutHorizontalAlignment;//当垂直布局时,每个元素在自己的单元格容器内,在水平方向上的位置.默认为MKUILayoutConstraintHorizontalAlignmentCenter

@property(nonatomic,assign) UIEdgeInsets contentInsets;//内边距,默认为(0,0,0,0)
- (CGSize)sizeThatFits:(CGSize)size resizeItems:(BOOL)resizeItems;
- (void)layoutItemsWithResizeItems:(BOOL)resizeItems;
@end

typedef enum : NSUInteger {
	MKUIFillingFlowLayoutConstraint_H_C,
	MKUIFillingFlowLayoutConstraint_H_T,
	MKUIFillingFlowLayoutConstraint_H_B,
	MKUIFillingFlowLayoutConstraint_V_C,
	MKUIFillingFlowLayoutConstraint_V_L,
	MKUIFillingFlowLayoutConstraint_V_R,
} MKUIFillingFlowLayoutConstraintParam;
MKAS_EnumTypeCategories(MKUIFillingFlowLayoutConstraintParam)
@interface MKUIFillingFlowLayoutConstraint (InitMethod)
- (id)initWithItems:(nullable NSArray<id<MKUILayoutConstraintItemProtocol>> *)items constraintParam:(MKUIFillingFlowLayoutConstraintParam)param contentInsets:(UIEdgeInsets)contentInsets;
@property(nonatomic,assign) MKUIFillingFlowLayoutConstraintParam constraintParam;
+ (void)parseConstraintParam:(MKUIFillingFlowLayoutConstraintParam)param layoutDirection:(MKUILayoutConstraintDirection *)layoutDirection layoutVerticalAlignment:(MKUILayoutConstraintVerticalAlignment *)layoutVerticalAlignment layoutHorizontalAlignment:(MKUILayoutConstraintHorizontalAlignment *)layoutHorizontalAlignment;
+ (MKUIFillingFlowLayoutConstraintParam)constraintParamWithLayoutDirection:(MKUILayoutConstraintDirection)layoutDirection layoutVerticalAlignment:(MKUILayoutConstraintVerticalAlignment)layoutVerticalAlignment layoutHorizontalAlignment:(MKUILayoutConstraintHorizontalAlignment)layoutHorizontalAlignment;
@end

NS_ASSUME_NONNULL_END

/**
 *
 以下为layoutDirection,layoutVerticalAlignment,layoutHorizontalAlignment的6种组合:
 self.fillingItem = C
 MKUIFillingFlowLayoutConstraint_H_C
 layoutDirection = MKUILayoutConstraintDirectionHorizontal;
 layoutVerticalAlignment = MKUILayoutConstraintVerticalAlignmentCenter;
 :
  __________
 |                    |
 |    B       D    |
 |A  B  C  D  E|
 |    B       D    |
 |__________|
 
 MKUIFillingFlowLayoutConstraint_H_T
 layoutDirection = MKUILayoutConstraintDirectionHorizontal;
 layoutVerticalAlignment = MKUILayoutConstraintVerticalAlignmentTop;
 :
  __________
 |A  B  C  D  E|
 |    B       D    |
 |    B       D    |
 |                    |
 |__________|
 
 MKUIFillingFlowLayoutConstraint_H_B
 layoutDirection = MKUILayoutConstraintDirectionHorizontal;
 layoutVerticalAlignment = MKUILayoutConstraintVerticalAlignmentBottom;
 :
  _____________
 |                            |
 |                            |
 |      B           D      |
 |      B           D      |
 |A__B__C__D__E|
 
 MKUIFillingFlowLayoutConstraint_V_C
 layoutDirection = MKUILayoutConstraintDirectionVertical;
 layoutHorizontalAlignment = MKUILayoutConstraintHorizontalAlignmentCenter;
 :
  ____
 |    A   |
 |         |
 | BBB |
 |         |
 |   C    |
 |          |
 | DDD |
 |          |
 |__E__|
 
 MKUIFillingFlowLayoutConstraint_V_L
 layoutDirection = MKUILayoutConstraintDirectionVertical;
 layoutHorizontalAlignment = MKUILayoutConstraintHorizontalAlignmentLeft;
 :
  ____
 |A       |
 |         |
 |BBB  |
 |         |
 |C      |
 |         |
 |DDD |
 |         |
 |E___|
 
 MKUIFillingFlowLayoutConstraint_V_R
 layoutDirection = MKUILayoutConstraintDirectionVertical;
 layoutHorizontalAlignment = MKUILayoutConstraintHorizontalAlignmentRight;
 :
  ____
 |       A|
 |         |
 |  BBB|
 |         |
 |      C|
 |         |
 |  DDD|
 |         |
 |___E|
 */
